#include <net/tcp_server.h>
#include <login.pb.h>
#include "LoginManager.h"

void DoAuthReq(TcpConn* c, const msg::AuthReq& req) {
    //处理请求
    uint64_t token = LoginManager::Instance().Auth(req.channel_id(), req.auth_code());

    //返回结果
    msg::AuthRsp rsp;
    rsp.set_token(token);
    c->Send(msg::LOGIN_PROTO_AUTH_RSP, rsp);
}

int main() {
    TcpServer s(8888);
    s.Register<msg::AuthReq>(msg::LOGIN_PROTO_AUTH_REQ, DoAuthReq);
    s.Run();
}